# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=re2
pkgver=2023.11.01
_pkgver=${pkgver//./-}
pkgrel=1
pkgdesc="Efficient, principled regular expression library"
url="https://github.com/google/re2"
arch="all"
license="BSD-3-Clause"
makedepends="
	abseil-cpp-dev
	cmake
	icu-dev
	samurai
	"
checkdepends="
	benchmark-dev
	gtest-dev
	"
subpackages="$pkgname-dev"
provides="libre2=$pkgver-r$pkgrel"
source="$pkgname-$pkgver.tar.gz::https://github.com/google/re2/archive/$_pkgver.tar.gz"
builddir="$srcdir"/$pkgname-$_pkgver

build() {
	export CXXFLAGS="$CXXFLAGS -O2 -flto=auto"
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON \
		-DRE2_USE_ICU=ON \
		-DRE2_BUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
9c7d6061e43b7332878d9f6c5265a0d096c55179b50ddf23382bc2ebbd79b02e416cbd36f451aaabe1bdf828baa7ce2a9deee37f90f77685a58da31143b55505  re2-2023.11.01.tar.gz
"
